<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('menus', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('parent_id')->default(0)->comment('父菜单ID');
            $table->string('title')->comment('菜单标题');
            $table->string('name')->nullable()->comment('菜单名称');
            $table->string('path')->nullable()->comment('路由地址');
            $table->string('component')->nullable()->comment('组件路径');
            $table->string('icon')->nullable()->comment('图标');
            $table->tinyInteger('type')->default(1)->comment('菜单类型：1-目录，2-菜单，3-按钮');
            $table->string('permission')->nullable()->comment('权限标识');
            $table->tinyInteger('status')->default(1)->comment('状态：1-启用，0-禁用');
            $table->integer('sort')->default(0)->comment('排序');
            $table->tinyInteger('hidden')->default(0)->comment('是否隐藏：1-隐藏，0-显示');
            $table->tinyInteger('keep_alive')->default(0)->comment('是否缓存：1-缓存，0-不缓存');
            $table->string('remark')->nullable()->comment('备注');
            $table->timestamps();
            $table->softDeletes();

            $table->index('parent_id');
            $table->index('status');
            $table->index('type');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('menus');
    }
};

